<%--
  Created by IntelliJ IDEA.
  User: 兰宦君
  Date: 2015/10/26
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
  <title>BookStore——我的网上书店</title>
  <%@ include file="../layout/import.jsp"%>
  <script language="JavaScript">
    function submit()
    {
      $.ajax({
        url: "/order.do",
        data: $('#payList').serialize(),
        method: "POST",
        dataType: "json",
        error: function () {
          alert("表单提交出错，请稍后再试");
        },
        success: function(response) {
          if(response.code == 0) {
            alert("下单成功");
            window.location.href = "/index.do";
          }
          else {
            alert(response.description);
          }
        }
      });
    }
  </script>
</head>
<body>
<%@include file="nav.jsp"%>
<div class="container" style="min-height: 75%">
  <form class="form-horizontal" id="payList">
    <div class="control-group">
      <label class="control-label" for="username">收货人</label>
      <div class="controls">
        <input type="text" class="form-control" name="receiver" id="username" value="${user.username}">
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="address">收货地址</label>
      <div class="controls">
        <input type="text" class="form-control" name="address" id="address" value="${user.address}">
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="phone">联系电话</label>
      <div class="controls">
        <input type="text" class="form-control" name="phone" id="phone" value="${user.phone}">
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="postcode">邮编</label>
      <div class="controls">
        <input type="text" class="form-control" name="postcode" id="postcode" value="${user.postcode}">
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="payment">付费方式</label>
      <div class="controls">
        <select class="form-control" id="payment" name="payment">
          <option value="邮局汇款">邮局汇款</option>
          <option value="银行转账">银行转账</option>
          <option value="货到付款">货到付款</option>
        </select>
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="deliver">送货方式</label>
      <div class="controls">
        <select name="deliver" id="deliver">
          <option value="24小时全国特快专递">24小时全国特快专递</option>
          <option value="邮局托运">邮局托运</option>
        </select>
      </div>
    </div>
  </form>
  <div class="text-center">
    <button type="submit" class="btn" onclick="submit()">立即下单</button>
  </div>
</div>
<%@include file="footer.jsp"%>
</body>
</html>
